package InsLoginRegister;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(name = "changePassword",urlPatterns ="/password")
public class changePassword extends HttpServlet {
    java.sql.Connection conn = null;
    String strConn;
    java.sql.Statement sqlStmt = null,sqlStmt1 = null;
    java.sql.ResultSet sqlRst = null,sqlRst1=null;
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
           try
           {
               Class.forName("org.h2.Driver");
               conn = java.sql.DriverManager.getConnection("jdbc:h2:~/jpa-demo-db;MODE=MYSQL;DB_CLOSE_DELAY=-1", "sa", "sa");
               sqlStmt = conn.createStatement();
               String mno = request.getParameter("mno");
               String password = request.getParameter("password");
               String sql = "update manager set password ="+"'"+password+"'"+" where mno = "+"'"+mno+"'";
               sqlStmt.executeUpdate(sql);
               response.sendRedirect("http://localhost:8084/html/sign-in.html");
           }catch (Exception ex)
           {
               System.out.println(ex.toString());
           }
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
